<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@include file="/common/jsp/taglibs-nojs-nocss.jsp"%>
<%
	String path = request.getContextPath();
	String basePath = request.getScheme() + "://"+ request.getServerName() + ":" + request.getServerPort()+ path + "/";
%>
<base href="<%=basePath%>"/>
<table  width="100%" border="0" align="center">
	<tr>
        <td style="width:50%;" align="center">
		    <div id="main_container" style="width:100%;">
			  <div id="container_border">
				 <div class="window_1">
			        	<div id="assistFee_div">
			            	<h3 class="priceRulelist_title_pic_2">【<s:property value="role.cname"/>】角色赋权</h3>
			        	</div>
		        </div>
		        <form id="chooseResc" name="chooseResc" action="userManager/saveR_Rescs.action" method="post" >
				    <div class="window_bottom">
				        <div id="pricerulemanage" style="height:400px;">
				            <table width="100%" border="0" cellpadding="0"  cellspacing="0" class="gridview"  id="pricerule_table">
				                <thead>
				                <tr class="title">
				                	<td style="width:30px">多选</td>
				                    <td>序号</td>
				                    <td >中文名称</td>
				                </tr>
				                </thead>
				                <tbody class="mytbody">
				                	<s:if test="rescList.size()==0">
				                		<tr>
				                			<td colspan="5" align="center">无记录</td>
				                		</tr>
				                	</s:if>
				                	<s:else>
				                		<input type="hidden" name="role.id" value="<s:property value="role.id"/>" />
						                <s:iterator value="rescList" status="stat">
								            <tr>
								            	<td style="width:30px">
								            		<input id="<s:property value="tree"/>" onclick="chooseUp(this.value)" type="checkbox" <s:property value="r_rescHaveMap.get(id)!=null?'checked':''"/> name="rescIds[<s:property value="#stat.index"/>]" value="<s:property value="id"/>"/>
								            		<input type="hidden" id="<s:property value="id"/>" value="<s:property value="tree"/>">
								            	</td>
								               	<td>
								               		<s:property value="tree"/>
								               	</td>
								               	<%String str = ""; %>
								                <td >
								                <% 
			                    		int j = request.getAttribute("tree").toString().split("\\.").length;
			                    		for(int i = 0 ; i < j-1;i++ ){
			                    			str = str + " -- ";
			                    		}
			                    	%>
			                    	<%=str%>
								                <s:property value="cname"/></td>
								            </tr>
								        </s:iterator>
				                	</s:else>
				                </tbody>
				            </table>
				        </div> 
				      </div>
			         <input type="submit" value="批量提交" />
			       </form>
		   	   </div>
		    </div>
		 </td>
 	</tr>
 </table>
<script type="text/javascript">
<!--
	function chooseUp(id){
		var resctree = document.getElementById(id).value;
		if(document.getElementById(resctree).checked){
			if(resctree.indexOf('.')!=-1){
				for(var i = 0 ; i < resctree.split('.').length;i++){
					if(resctree.indexOf('.')!=-1){
						resctree = resctree.substring(0,resctree.lastIndexOf('.'));
					}
					document.getElementById(resctree).checked='checked';
				}
			}
		}else{
			var inputs = document.getElementsByTagName("input");//获取所有的input标签对象
			var checkboxArray = [];//初始化空数组，用来存放checkbox对象。
			for(var i=0;i<inputs.length;i++){
			  var obj = inputs[i];
			  if(obj.type=='checkbox'){
				  if(obj.id.indexOf(resctree+".") != -1 && document.getElementById(obj.id).checked){
					  document.getElementById(obj.id).checked='';
				  }
			  }
			}
		}
	}
//-->
</script>
